<template>
	<view class="padding30">
		<!-- 直推或者间推奖励 -->
		<view class="h162 pl50 bg-f radius16 flex row-column row-center">
			<view class="fw-700 fs46" style="font-family: DINAlternate-Bold, DINAlternate;">{{total}}</view>
			<view class="color9 fs26">{{name}}</view>
		</view>
		
		<!-- //选择时间 -->
		<timeSelect @seartime='search_time'/>
		<!-- //列表盒子 -->
		<moneyList :list="moneyList" @/>
	</view>
</template>

<script>
	import timeSelect from '@/components/time_select.vue'
	import moneyList from '@/components/money_list.vue'
	export default {
		onLoad(opt) {
			this.from=opt.from
			if(opt.from==2) {
				uni.setNavigationBarTitle({
					title:'间推奖励'
				})
				this.query.type=3
				this.name='间推奖励'
			}
			this.total=opt.total
			this.getwallet_info()
		},
		components: { timeSelect, moneyList },
		data() {
			return {
				//如果from==1是直推奖励,==2是间推奖励
				from:'',
				name:"直推奖励",
				// 查询参数
				query:{
					page:1,
					size:20,
					type:2,
					timestart:'',
					timeend:''
				},
				total:'',
				moneyList:[],
				count:''
			};
		},
		methods:{
			getwallet_info(cd) {
				this.$api.wallet_info(this.query).then(res=>{
					console.log(res)
					this.count=res.data.count
					cd? this.moneyList=[...this.moneyList,...res.data.data] : this.moneyList=res.data.data
				})
			},
			search_time(timestart,timeend) {
				this.query.timestart=timestart
				this.query.timeend=timeend
				this.query.page=1
				this.getwallet_info()
			}
		},
		onReachBottom() {
			if(this.count>this.moneyList.length) {
				this.query.page++
				this.getwallet_info('cd')
			}else {
				this.$msg('暂无更多数据')
			}
		}
	}
</script>

<style lang="scss">

</style>
